<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>添加限时抢购</title>


    <link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/js/jquery.validate.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/editor/kindeditor.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
    <script type="text/javascript" src="${base}/resources/admin/datePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        $().ready(function () {

            var $inputForm = $("#inputForm");
            var $browserButton = $("#browserButton");

        [@flash_message /]

            $browserButton.browser();

            // 表单验证
            $inputForm.validate({
                rules: {
                    sn: "required"
                }
            });

        });
    </script>
</head>
<body>
<div class="path">
    <a href="${base}/asl-admin/common/index.htm">${message("admin.path.index")}</a> &raquo; 添加限时抢购
</div>
<form id="inputForm" action="save.htm" method="post">
    <table class="input">
        <tr>
            <th>
                <span class="requiredField">*</span>商品编号:
            </th>
            <td>
                <input type="text" placeholder="输入产品编号" name="sn" class="text" maxlength="200" id="sn"/>
                <span id="proTxt" style="color: red"></span>
            </td>
        </tr>
        <tr>
            <th> ${message("Coupon.beginDate")}:</th>
            <td>
                <input type="text" id="beginDate" name="beginDate" class="text Wdate"
                       onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss', maxDate: '#F{$dp.$D(\'endDate\')}'});"/>
                <span>该项为空时，表示一经启用，就可以接受抢购</span>
            </td>
        </tr>
        <tr>
            <th> ${message("Coupon.endDate")}:</th>
            <td>
                <input type="text" id="endDate" name="endDate" class="text Wdate"
                       onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss', minDate: '#F{$dp.$D(\'beginDate\')}'});"/>
                <span>该项为空时，表示一经启用，可以无限期抢购</span>
            </td>
        </tr>
        <tr>
            <th> ${message("admin.common.setting")}:</th>
            <td>
                <label>
                    <input type="checkbox" name="enable" checked value="true"/>${message("Coupon.isEnabled")}
                </label>
            </td>
        </tr>
    </table>
    <table class="input">
        <tr>
            <th>
                &nbsp;
            </th>
            <td>
                <input type="submit" id="submit" class="button" disabled value="${message("admin.common.submit")}"/>
                <input type="button" class="button" value="${message("admin.common.back")}"
                       onclick="location.href='list.htm'"/>
            </td>
        </tr>
    </table>
</form>
<script type="text/javascript">
    $("#sn").on("blur", function () {
        var sn=$(this).val();
        if ($(this).val()){
            $.get("/asl-admin/giveaway/product.htm",{sn:sn}).done(function(data){
                if (data.code==0){
                    $("#proTxt").html(data.data);
                    $("#submit").removeAttr("disabled");
                }else{
                    $("#proTxt").html("该商品不存在！");
                    $("#submit").attr("disabled","disabled");
                }
            });
        }
    });


</script>
</body>
</html>
